package com.ruoyi.carbon.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.carbon.domain.ScmSaleDelivery;
import com.ruoyi.carbon.service.IScmSaleDeliveryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 销售发货单Controller
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/carbon/ScmSaleDelivery")
public class ScmSaleDeliveryController extends BaseController
{
    @Autowired
    private IScmSaleDeliveryService scmSaleDeliveryService;

    /**
     * 查询销售发货单列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:ScmSaleDelivery:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmSaleDelivery scmSaleDelivery)
    {
        startPage();
        List<ScmSaleDelivery> list = scmSaleDeliveryService.selectScmSaleDeliveryList(scmSaleDelivery);
        return getDataTable(list);
    }

    /**
     * 导出销售发货单列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:ScmSaleDelivery:export')")
    @Log(title = "销售发货单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmSaleDelivery scmSaleDelivery)
    {
        List<ScmSaleDelivery> list = scmSaleDeliveryService.selectScmSaleDeliveryList(scmSaleDelivery);
        ExcelUtil<ScmSaleDelivery> util = new ExcelUtil<ScmSaleDelivery>(ScmSaleDelivery.class);
        util.exportExcel(response, list, "销售发货单数据");
    }

    /**
     * 获取销售发货单详细信息
     */
    @PreAuthorize("@ss.hasPermi('carbon:ScmSaleDelivery:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmSaleDeliveryService.selectScmSaleDeliveryById(id));
    }

    /**
     * 新增销售发货单
     */
    @PreAuthorize("@ss.hasPermi('carbon:ScmSaleDelivery:add')")
    @Log(title = "销售发货单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmSaleDelivery scmSaleDelivery)
    {
        return toAjax(scmSaleDeliveryService.insertScmSaleDelivery(scmSaleDelivery));
    }

    /**
     * 修改销售发货单
     */
    @PreAuthorize("@ss.hasPermi('carbon:ScmSaleDelivery:edit')")
    @Log(title = "销售发货单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmSaleDelivery scmSaleDelivery)
    {
        return toAjax(scmSaleDeliveryService.updateScmSaleDelivery(scmSaleDelivery));
    }

    /**
     * 删除销售发货单
     */
    @PreAuthorize("@ss.hasPermi('carbon:ScmSaleDelivery:remove')")
    @Log(title = "销售发货单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmSaleDeliveryService.deleteScmSaleDeliveryByIds(ids));
    }
}
